package com.gugee.ins.common.dal.mapper.statistics;

import com.gugee.common.mapper.GugeeMapper;
import com.gugee.ins.common.model.es.StatisticsData;
import com.gugee.ins.common.model.mysql.statistics.InsStBloggerLanguage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface InsStBloggerLanguageMapper extends GugeeMapper<InsStBloggerLanguage> {

    @Delete("delete from ins_st_blogger_language where uid = #{uid}")
    void deleteByUid(long uid);

    @Select("SELECT b.language language,count(*) languageRate " +
            "FROM ins_rel_blogger_active_follower ba LEFT JOIN ins_blogger b ON ba.f_uid = b.uid " +
            "WHERE ba.uid = #{uid} and b.language is not null and b.language != 'un' GROUP BY  b.language ORDER BY languageRate DESC limit 0,#{size} ")
    List<InsStBloggerLanguage> findByActiveFollower(long uid, int size);


    @Select("select * from ins_st_blogger_language WHERE uid = #{uid} ORDER BY language_rank ")
    List<InsStBloggerLanguage> findByUid(long uid);

    @Select("select language `property`,language_rank `rank`,language_rate `value` from ins_st_blogger_language WHERE uid = #{uid} ORDER BY language_rank ")
    List<StatisticsData> findStatisticsDataByUid(long uid);
}